package com.kotlin.android.mtime.ktx.ext

import android.view.View
import androidx.annotation.ColorRes
import com.kotlin.android.ktx.ext.px
import com.kotlin.android.ktx.ext.setSelector
import com.kotlin.android.mtime.ktx.R

/**
 * MTime相关View扩展
 *
 * Created on 2020/6/9.
 *
 * @author o.s
 */

/**
 * 根据项目要求设置默认的内边距，一般不需要改动（dp）
 */
fun View.setNormalPadding(
    left: Int = 2,
    top: Int = 1,
    right: Int = 2,
    bottom: Int = 1
) {
    setPadding(left.px, top.px, right.px, bottom.px)
}

/**
 * View设置选择器，指定圆角 [cornerRadius]（dp），边框 [strokeWidth]
 */
fun View.setSelector(
    @ColorRes pressColor: Int = R.color.color_dbb177,
    @ColorRes normalColor: Int = R.color.color_d1a568,
    cornerRadius: Int = 30,
    strokeWidth: Int = 1
): View {
    return setSelector(
        pressColor,
        pressColor,
        normalColor,
        normalColor,
        cornerRadius,
        strokeWidth
    )
}